/*
题目地址:https://leetcode-cn.com/problems/water-bottles/
题目标签:数学
*/

#include <iostream>

class Solution {
   public:
    int numWaterBottles(int numBottles, int numExchange) {
        // 每兑换一次，均会减少(numExchange - 1)个空瓶；
        // 最后一次兑换必须有numExchange个空瓶子才能兑换。
        return numBottles + (numBottles - 1) / (numExchange - 1);
    }
};

int main() {
    Solution Solution;
    std::cout << Solution.numWaterBottles(9, 3) << std::endl;   // 13
    std::cout << Solution.numWaterBottles(15, 4) << std::endl;  // 19
    std::cout << Solution.numWaterBottles(5, 5) << std::endl;   // 6
    std::cout << Solution.numWaterBottles(2, 3) << std::endl;   // 2
}